package com.xoa.controller.party;


import com.xoa.model.party.OrgDepartment;
import com.xoa.model.party.OrgDepartmentWithBLOBs;
import com.xoa.service.party.OrgDepartmentService;
import com.xoa.util.ToJson;
import com.xoa.util.common.wrapper.BaseWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import java.beans.Transient;

@RestController
@RequestMapping("orgDepartment")
public class OrgDepartmentController {
    @Autowired
    private OrgDepartmentService orgDepartmentService;

    /**
     * 张丽军
     * 组织结构新增接口
     * @param orgDepartment
     * @return
     */
    @RequestMapping("addOrgDepartment")
    public BaseWrapper addOrgDepartment(OrgDepartmentWithBLOBs orgDepartment){
        return  orgDepartmentService.addOrgDepartment(orgDepartment);
    }

    /**
     * 张丽军
     * 组织架构修改接口
     * @param orgDepartment
     * @return
     */
    @RequestMapping("updateOrgDepartment")
    public BaseWrapper updateOrgDepartment(OrgDepartmentWithBLOBs orgDepartment){
        return  orgDepartmentService.updateOrgDepartment(orgDepartment);
    }

    /**
     * 张丽军
     * 组织架构树结构接口
     * @param deptId
     * @return
     */
    @RequestMapping("queryByDepIdList")
    public ToJson<OrgDepartmentWithBLOBs> queryByDepIdList(Integer deptId){
        return  orgDepartmentService.queryByDepIdList(deptId);
    }

    /**
     *  张丽军
     *  方法介绍：组织架构根据组织id查询列表接口
     * @param request
     * @param orgDepartment
     * @return
     */
    @RequestMapping("queryDepIdList")
    public ToJson<OrgDepartmentWithBLOBs> queryDepIdList(HttpServletRequest request, OrgDepartment orgDepartment){
        return  orgDepartmentService.queryDepIdList(orgDepartment);
    }
    @RequestMapping("/getChDept")
    public ToJson getChDept(Integer deptId){
        return orgDepartmentService.getChDept(deptId);
    }
    /**
     * 张丽军
     * 组织架构管理详情接口
     * @param request
     * @param deptId
     * @return
     */
    @RequestMapping("queryByIdOrgDepartmentWithBLOBs")
    public BaseWrapper queryByIdOrgDepartmentWithBLOBs(HttpServletRequest request, Integer deptId){
        return  orgDepartmentService.queryByIdOrgDepartmentWithBLOBs(request,deptId);
    }

    //查询全部党支部

    @ResponseBody
    @RequestMapping("/selectSum")
    public ToJson selectSum(){
             return orgDepartmentService.selectSum();
    }
    //查询党支部分组
    @ResponseBody
    @RequestMapping("/selectSumGroup")
    public ToJson selectSumGroup(){
        return orgDepartmentService.selectSumGroup();
    }

    //导入党组织
    @RequestMapping("/ecoudInsert")
    @ResponseBody
    @Transient
    public ToJson ecoudInsert(MultipartFile file){
        return orgDepartmentService.ecoudInsert(file);
    }

    //党建查找接口
    public ToJson selectbylocation(String location){
        return orgDepartmentService.selectbylocation(location);
    }

    //党建查找只查党组织
    @RequestMapping("/selectByLocation")
    @ResponseBody
    public ToJson selectbylocationOrgdepart(String location){
        return orgDepartmentService.selectbyLocationOrgDepart(location);
    }
    /**
     * 郭心雨
     * 删除组织架构
     * @param deptId
     * @return
     */
    @RequestMapping("delDepartment")
    public ToJson<OrgDepartment> delDepartment(Integer deptId, HttpServletRequest request){
        return  orgDepartmentService.delDepartment(deptId,request);
    }
    /**
     *  王辰
     *  2020/08/24
     *  党支部删除
     *
     */
    @RequestMapping("delDepById")
    public ToJson delDepById(Integer deptId,HttpServletRequest request){
        return orgDepartmentService.delDepById(deptId);
    }
/**
 *  王辰
 *  2020/08/24
 *  党支部列表数据
 *
*/
    @RequestMapping("/getPartyList")
    public ToJson getPartyList(){
        return orgDepartmentService.getPartyList();
    }

    @RequestMapping("/getPartyDeptById")
    @ResponseBody
    public ToJson getPartyDeptById(HttpServletRequest request,Integer orgDeptId){
        return orgDepartmentService.getPartyDeptById(request,orgDeptId);
    }
}
